<cffunction name="$generatedKey" returntype="string" access="public" output="false">
	<cfreturn "generated_key">
</cffunction>

<cffunction name="$randomOrder" returntype="string" access="public" output="false">
	<cfreturn "RAND()">
</cffunction>

<cffunction name="$getType" returntype="string" access="public" output="false">
	<cfargument name="type" type="string" required="true">
	<cfscript>
		var loc = {};
		switch(arguments.type)
		{
			case "bigint": case "int8": {loc.returnValue = "cf_sql_bigint"; break;}
			case "binary": case "bytea": case "raw": {loc.returnValue = "cf_sql_binary"; break;}
			case "bit": case "bool": case "boolean": {loc.returnValue = "cf_sql_bit"; break;}
			case "blob": case "tinyblob": case "mediumblob": case "longblob": case "image": case "oid": {loc.returnValue = "cf_sql_blob"; break;}
			case "char": case "character": case "nchar": {loc.returnValue = "cf_sql_char"; break;}
			case "date": {loc.returnValue = "cf_sql_date"; break;}
			case "dec": case "decimal": case "number": case "numeric": {loc.returnValue = "cf_sql_decimal"; break;}
			case "double": {loc.returnValue = "cf_sql_double"; break;}
			case "float": case "float4": case "float8": case "real": {loc.returnValue = "cf_sql_float"; break;}
			case "int": case "int4": case "integer": case "mediumint": case "signed": {loc.returnValue = "cf_sql_integer"; break;}
			case "int2": case "smallint": case "year": {loc.returnValue = "cf_sql_smallint"; break;}
			case "time": {loc.returnValue = "cf_sql_time"; break;}
			case "datetime": case "smalldatetime": case "timestamp": {loc.returnValue = "cf_sql_timestamp"; break;}
			case "tinyint": {loc.returnValue = "cf_sql_tinyint"; break;}
			case "varbinary": case "longvarbinary": {loc.returnValue = "cf_sql_varbinary"; break;}
			case "varchar": case "varchar2": case "longvarchar": case "nvarchar": case "nvarchar2": case "clob": case "nclob": case "text": case "tinytext": case "mediumtext": case "longtext": case "ntext": {loc.returnValue = "cf_sql_varchar"; break;}
		}
	</cfscript>
	<cfreturn loc.returnValue>
</cffunction>

<cffunction name="$query" returntype="struct" access="public" output="false">
	<cfargument name="sql" type="array" required="true">
	<cfargument name="limit" type="numeric" required="false" default=0>
	<cfargument name="offset" type="numeric" required="false" default=0>
	<cfargument name="parameterize" type="boolean" required="true">
	<cfargument name="$primaryKey" type="string" required="false" default="">
	<cfscript>
		var loc = {};
		arguments.sql = $removeColumnAliasesInOrderClause(arguments.sql);

		if (StructKeyExists(server, "railo") AND left(arguments.sql[1], 11) eq "INSERT INTO")
			arguments.$getid = true;

		loc.returnValue = $performQuery(argumentCollection=arguments);
	</cfscript>
	<cfreturn loc.returnValue>
</cffunction>

<cffunction name="$identitySelect" returntype="struct" access="public" output="false">
	<cfargument name="queryargs" type="struct" required="true">
	<cfargument name="result" type="struct" required="true">
	<cfargument name="args" type="struct" required="true">
	<cfset var loc = {}>
	<cfset var query = {}>
	<cfset loc.returnValue = {}>
	<cfquery attributeCollection="#arguments.queryargs#">SELECT LAST_INSERT_ID() AS lastId</cfquery>
	<cfset loc.returnValue.generated_key = query.name.lastId>
	<cfreturn loc.returnValue>
</cffunction>